<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>注册</title>
<link rel="stylesheet" type="text/css" href="res/css/css.css"/>
<script type="text/javascript" src="res/js/jquery.js"></script>
<script type="text/javascript" src="res/js/js.js"></script>
<script type="text/javascript" src="res/js/base64-min.js"></script>
<link rel="shortcut icon" href="favicon.ico" />
<style>
<?php
$col = getconfig('apptheme','#336699');
echo 'body{--main-color:'.$col.'}';
?>
.input{border-radius:5px}
</style>
<script>
function initbody(){
	reshuacode();
}

function submintreg(o1){
	var da = js.getformdata();
	js.setmsg();
	if(!da.mobile){
		js.setmsg('请输入手机号');
		return;
	}
	if(!da.mobilecode && da.mobile.length!=11){
		js.setmsg('请输入11位手机号');
		return;
	}
	if(!da.smscode){
		js.setmsg('请输入短信验证码');
		return;
	}
	if(!da.name){
		js.setmsg('请输入姓名');
		return;
	}
	if(da.pass.length<4){
		js.setmsg('密码不能少于4个字符');
		return;
	}
	if(!/[a-zA-Z]{1,}/.test(da.pass) || !/[0-9]{1,}/.test(da.pass)){
		js.setmsg('密码必须使用字母+数字');
		return false;
	}
	if(da.pass!=da.pass1){
		js.setmsg('确认密码一致');
		return false;
	}
	js.setmsg('注册中...');
	o1.disabled=true;
	da.device = device;
	da.cform  = 'pcweb';
	js.ajax({
		url:js.apiurl('login','regcheck'),
		data:da,
		type:'post',
		dataType:'json',
		success:function(ret){
			if(ret.success){
				js.setmsg('注册成功','green');
				js.msgok('注册成功，去登录',function(){
					js.back();
				},1);
			}else{
				js.setmsg(ret.msg);
				o1.disabled=false;
			}
		}
	});
}
function reshuacode(){
	var url = js.apiurl('login','imgcode', {device:device});
	var o1 = get('imgcodeimg');
	o1.src = url;
}
function getcode(){
	js.setmsg();
	var da = js.getformdata();
	if(!da.mobile){
		js.msg('msg','请输入手机号');
		form('mobile').focus();
		return;
	}
	if(!da.mobilecode && da.mobile.length!=11){
		js.msg('msg','请输入11位手机号');
		form('mobile').focus();
		return;
	}
	if(!da.imgcode){
		js.msg('msg','请输入计算验证结果');
		form('imgcode').focus();
		return;
	}
	var o1 = get('getcodebtn');
	o1.disabled=true;
	o1.value='获取中..';
	js.ajax({
		url:js.apiurl('login','getcode'),
		data:{device:device,gtype:'reg',mobilecode:da.mobilecode,mobile:da.mobile,imgcode:da.imgcode},
		type:'post',
		dataType:'json',
		success:function(ret){
			if(ret.success){
				o1.value='获取成功';
				js.msg('success',ret.data.msg);
				dshitime(60, o1);
			}else{
				js.msg('msg',ret.msg);
				o1.disabled=false;
				o1.value='重新获取';
			}
			reshuacode();
		},
		error:function(){
			js.msg('msg','获取失败');
			o1.disabled=false;
			o1.value='重新获取';
		}
	});
}

function dshitime(sj,o1){
	if(sj==0){
		o1.disabled=false;
		o1.value='重新获取';
		return;
	}
	o1.disabled=true;
	o1.value=''+sj+'';
	setTimeout(function(){dshitime(sj-1, o1)},1000);
}
</script>
</head>


<body>

<div align="center">
	<div style="width:400px;max-width:100%" align="left">
		<div align="center" ondblclick="js.reload()" style="padding:10px;padding-top:15px;;border-bottom:1px #dddddd solid"><h3>注册</h3></div>
		<div style="background:white;padding:20px 10px;border-radius:5px">
			<form name="myform">
			<table>
			<tr>
				<td width="100px" align="right"><font color="red">*</font>手机号&nbsp;&nbsp;</td>
				<td>
				<select style="width:70px;border-radius:5px 0px 0px 5px;border-right:0px;height:36px" class="input" name="mobilecode"><option value="">+86</option></select><input maxlength="11" placeholder="请输入手机号" style="width:130px;border-radius:0px 5px 5px 0px" class="input" name="mobile">
				</td>
			</tr>
			<tr><td height="15px"></td></tr>
			
			<tr>
				<td align="right"><font color="red">*</font>计算验证&nbsp;&nbsp;</td>
				<td>
				<input placeholder="请输入计算结果" maxlength="2" style="width:130px;border-radius:5px 0px 0px 5px;border-right:0px;" class="input" name="imgcode"><div style="height:34px;width:70px;border:1px #dddddd solid;float:right;border-radius:0px 5px 5px 0px;cursor:pointer;"><img onclick="reshuacode()" id="imgcodeimg" align="absmiddle" src=""></div>
				</td>
			</tr>
			<tr><td height="15px"></td></tr>
			
			<tr>
				<td width="100px" align="right"><font color="red">*</font>短信验证码&nbsp;&nbsp;</td>
				<td>
				<input maxlength="6" placeholder="短信验证码" style="width:131px;border-radius:5px 0px 0px 5px;border-right:0px;" class="input" name="smscode"><input type="button" style="height:36px;width:70px;border:1px #dddddd solid;border-radius:0px 5px 5px 0px;background:#f1f1f1;cursor:pointer;" onclick="getcode()" id="getcodebtn" value="获取">
				
				</td>
			</tr>
			<tr><td height="15px"></td></tr>
			
			<tr>
				<td align="right"><font color="red">*</font>姓名&nbsp;&nbsp;</td>
				<td><input placeholder="请输入姓名/昵称" style="width:200px" class="input" name="name"></td>
			</tr>
			<tr><td height="15px"></td></tr>
			
			<tr>
				<td align="right"><font color="red">*</font>密码&nbsp;&nbsp;</td>
				<td><input placeholder="英文数字组合至少4位" style="width:200px" type="password" class="input" name="pass"></td>
			</tr>
			<tr><td height="15px"></td></tr>
			
			<tr>
				<td align="right"><font color="red">*</font>确认密码&nbsp;&nbsp;</td>
				<td><input placeholder="" style="width:200px" class="input" name="pass1" type="password"></td>
			</tr>
			<tr><td height="15px"></td></tr>
			
			<tr>
				<td align="right"></td>
				<td><button type="button" onclick="submintreg(this)" style="padding:8px 20px"  class="webbtn">注册</button>&nbsp;<span id="msgview"><font color=gray>已有账号，去<a onclick="js.back()" href="javascript:;" class="zhu">登录</a></font></span></td>
			</tr>
			
			
			</table>
			</form>
		</div>
	</div>
</div>


<script type="text/javascript" src="res/js/jquery-rockmodels.js"></script>
</body>
</html>